package com.javaee.dao;

import com.javaee.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ActivitiesDao {
    @Insert("insert into t_manager_activity (id,name, category, title, creator, abstract, detailed_desc, status, created_time, archived_time, pic_urls, start_time, end_time) values(#{id},#{name}, #{category}, #{title}, #{creator}, #{abstracts}, #{detailed_desc}, #{status}, #{created_time}, #{archived_time}, #{pic_urls}, #{start_time}, #{end_time})")
    public int create(Activity activity);

    @Update("update t_manager_activity set name = #{name}, category = #{category}, title = #{title}, creator = #{creator}, abstract = #{abstracts}, detailed_desc = #{detailed_desc}, status = #{status}, created_time = #{created_time}, archived_time = #{archived_time}, pic_urls = #{pic_urls}, start_time = #{start_time}, end_time = #{end_time} where id = #{id}")
    public int update(Activity activity);

    @Update("update t_manager_activity set status = 1 where id = #{id}")
    public int publish(int id);

    @Select("select * from t_manager_activity where status = #{status} order by created_time DESC")
    public List<Activity> getByStatus(Integer status);

    @Select("select * from t_manager_activity where name LIKE #{name} order by created_time DESC")
    public List<Activity> getByName(String name);
}
